package com.tweetbook.ui.services;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tweetbook.entity.Account.AccountFactory;

/**
 * Servlet implementation class ValidateUser
 */
@WebServlet("/ValidateUser")
public class ValidateUser extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private AccountFactory af = new AccountFactory();
       
    public ValidateUser() {
        super();
    }


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		String loginid = request.getParameter("loginid");
		String passwd  = request.getParameter("passwd1");
		int error = af.checkAccount(loginid, passwd);
		if(error ==0){
			response.sendRedirect("/project/LoginError.html");
		}
		else{
			
			response.sendRedirect("/project/home.html");
		}
	}

}
